# Maintainer: Jaroslav Lichtblau <svetlemodry@archlinux.org>
# Contributor: Eli Schwartz <eschwartz@archlinux.org>

_pkgname=rawkit
pkgname=python-rawkit
pkgver=0.6.0
pkgrel=12
pkgdesc="ctypes based libraw bindings "
arch=('any')
url="https://rawkit.readthedocs.io/"
license=('MIT')
depends=('libraw' 'python')
makedepends=('python-setuptools')
checkdepends=('python-mock' 'python-pytest')
source=(${_pkgname}-${pkgver}.tar.gz::https://github.com/photoshell/rawkit/archive/v${pkgver}.tar.gz
        https://github.com/photoshell/rawkit/pull/140/commits/663e90afa835d398aedd782c87b8cd0bff64bc9f.patch
        libraw19-support.patch)
sha256sums=('c07971ddbca9568cef93753ebb06a72b5b622f9b827a5d8bf96f2a137cc4219e'
            '1297740c3825d41b394808b3be145d0f41effc415e5dbd6fd1e17e51328ce418'
            '104598076673c435f863cd25508060c0f2639b46d0fdcce7fa89b7723af443c5')

prepare() {
  cd "${srcdir}"/${_pkgname}-${pkgver}

  # python 3.7
  patch -p1 -i "${srcdir}"/663e90afa835d398aedd782c87b8cd0bff64bc9f.patch
  # FS#60708 fix
  patch -p1 -i "${srcdir}"/libraw19-support.patch
}

build() {
  cd "${srcdir}"/${_pkgname}-${pkgver}

  python setup.py build
}

check() {
  cd "${srcdir}"/${_pkgname}-${pkgver}

  python -m pytest
}

package_python-rawkit() {
  cd "${srcdir}"/${_pkgname}-${pkgver}
  python setup.py install --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}
